package com.zjw.controller;


import com.zjw.annotation.domain.ResponseResult;
import com.zjw.annotation.domain.dto.SaveArticleDto;
import com.zjw.annotation.domain.dto.UpdateArticleDto;
import com.zjw.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content")
public class ContentController {

    @Autowired
    private ArticleService articleService;

    @PostMapping("/article")
    @PreAuthorize("@Ps.hasPermission('content:article:writer')")
    public ResponseResult saveArticle(@RequestBody SaveArticleDto saveArticleDto) {
        return articleService.saveArticle(saveArticleDto);
    }

    @PutMapping("/article")
    @PreAuthorize("@Ps.hasPermission('content:article:writer')")
    public ResponseResult updateArticle(@RequestBody UpdateArticleDto  updateArticleDto){
        return articleService.updateArticle(updateArticleDto);
    }

}
